//
//  AddressTableViewCell.m
//  EasyToTesco2.0
//
//  Created by 袖手旁觀 on 16/8/9.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "AddressTableViewCell.h"

@implementation AddressTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self loadAddressUI];
    }
    return self;
}

- (void)loadAddressUI {
    
    CGFloat cellWidth = (self.contentView.width - self.imageView.width) / 2;
    
    self.nameLabel = [[UILabel alloc] init];
    self.nameLabel.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:self.nameLabel];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).with.offset(8);
        make.left.equalTo(self.imageView.mas_right).with.offset(8);
        make.width.mas_equalTo(cellWidth);
        make.height.mas_equalTo(20);
    }];
    
    self.phoneNumberLabel = [[UILabel alloc] init];
    self.phoneNumberLabel.font = [UIFont systemFontOfSize:16];
    self.phoneNumberLabel.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:self.phoneNumberLabel];
    
    [self.phoneNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView.mas_right).with.offset(-8);
        make.top.equalTo(self.nameLabel.mas_top);
        make.width.mas_equalTo(cellWidth);
        make.height.mas_equalTo(20);
    }];
    
    self.addressLabel = [[UILabel alloc] init];
    self.addressLabel.font = [UIFont systemFontOfSize:15];
    self.addressLabel.numberOfLines = 0;
    [self.contentView addSubview:self.addressLabel];
    
    [self.addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.mas_left);
        make.top.equalTo(self.nameLabel.mas_bottom).with.offset(4);
        make.width.mas_equalTo(self.contentView.width - self.nameLabel.x - 8);
        make.height.mas_equalTo(HEIGHT/9 - 26);
    }];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
